package com.lu.manage.modular.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lu.manage.core.utils.ToolUtil;
import com.lu.manage.modular.system.model.Menu;
import com.lu.manage.modular.system.service.ConstantService;
import com.lu.manage.modular.system.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program LuBoot
 * @description:
 * @author: zhanglu
 * @create: 2019-11-03 21:41:00
 */
@Service
public class ConstantServiceImpl implements ConstantService {

    @Autowired
    private MenuService menuService;

    @Override
    public String getMenuNameByCode(String code) {

        if(ToolUtil.isEmpty(code)){
            return "";
        }else if(code.equals("0")){
            return "顶级";
        }else {
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("code", code);
            Menu menu = menuService.getBaseMapper().selectOne(queryWrapper);
            if(ToolUtil.isEmpty(menu)){
                return "";
            }else {
                return menu.getName();
            }
        }
    }

}
